<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:bil="http://java.sun.com/jsf/composite/bill"
      xmlns:phi="http://java.sun.com/jsf/composite/pharmacy"
      xmlns:pa="http://java.sun.com/jsf/composite/paymentMethod"
      xmlns:pat="http://java.sun.com/jsf/composite/patient">

    <h:body>


        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">



                <h:form id="bill" >
                    <p:commandButton id="nullButton2" value="No Action" action="#" style="display: none;" ></p:commandButton>
                    <p:defaultCommand  target="btnAdd" />  

                    <p:panel rendered="#{!pharmacySaleController3.billPreview}"  >
                        <h:panelGroup id="panelError" >
                            <h:panelGroup  
                                rendered="#{pharmacySaleController3.errorMessage ne null}"
                                style="background-color: yellow; color: red; display: block; margin: 2px; border: 1px solid red; padding: 3px; width: 95%;">
                                <p:outputLabel value="#{pharmacySaleController3.errorMessage}" ></p:outputLabel>
                            </h:panelGroup>
                        </h:panelGroup>

                        <p:panel>
                            <p:commandButton value="Sale 1" action="pharmacy_bill_retail_sale" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController.pharmacyRetailSale()}" />
                            <p:commandButton value="Sale 2" action="pharmacy_bill_retail_sale_1" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController1.pharmacyRetailSale()}" />
                            <p:commandButton value="Sale 3" action="pharmacy_bill_retail_sale_2" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController2.pharmacyRetailSale()}" />
                            <p:commandButton disabled="true" value="Sale 4" action="pharmacy_bill_retail_sale_3" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController3.pharmacyRetailSale()}" />
                        </p:panel>

                        <h:panelGrid id="sale" columns="2" class="alignTop" >


                            <p:panel >
                                <f:facet name="header" >
                                    <h:outputLabel value="Pharmacy Retail Bill(Sale 4)" />
                                </f:facet>
                                <h:panelGrid columns="1" >
                                    <h:panelGrid columns="6" >
                                        <h:panelGrid columns="1" >
                                            <p:outputLabel value="Medicines/Devices" ></p:outputLabel>
                                            <style>
                                                .ui-autocomplete-input {width:350px!important;display: block;}
                                                .ui-autocomplete{display: block!important;}
                                            </style>
                                            <p:autoComplete accesskey="i"    id="acStock" 
                                                            value="#{pharmacySaleController3.stock}" 
                                                            converter="stockCon" 
                                                            completeMethod="#{pharmacySaleController3.completeAvailableStocksFromNameOrGeneric}" 
                                                            var="i" itemLabel="#{i.itemBatch.item.name}" itemValue="#{i}" 
                                                            >
                                                <p:column headerText="Item">
                                                    <h:outputLabel value="#{i.itemBatch.item.name}"  style="width: 300px!important;
                                                                   #{commonController.currentDateTime > i.itemBatch.dateOfExpire ?'color: red; ': 
                                                                     commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'color: red; background-color: yellow;':''}"></h:outputLabel>
                                                </p:column>
                                                <p:column headerText="Code">
                                                    <h:outputLabel value="#{i.itemBatch.item.code}" style="width: 50px!important;"></h:outputLabel>
                                                </p:column>
                                                <p:column headerText="Generic">
                                                    <h:outputLabel value="#{i.itemBatch.item.vmp.name}" style="width: 150px!important;"></h:outputLabel>
                                                </p:column>
                                                <p:column headerText="Rate">
                                                    <h:outputLabel value="#{i.itemBatch.retailsaleRate}"  style="width: 50px!important;">
                                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                    </h:outputLabel>
                                                </p:column>
                                                <p:column headerText="Stocks">
                                                    <h:outputLabel value="#{i.stock}"  style="width: 50px!important;">
                                                        <f:convertNumber pattern="#,###" ></f:convertNumber>
                                                    </h:outputLabel>
                                                </p:column>
                                                <p:column headerText="Expiry">
                                                    <h:outputLabel value="#{i.itemBatch.dateOfExpire}"  
                                                                   style="width: 100px!important;
                                                                   #{commonController.currentDateTime > i.itemBatch.dateOfExpire ?'color: red;': 
                                                                     commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'color: red; background-color: yellow;':''}">
                                                        <f:convertDateTime pattern="dd/MM/yyyy" ></f:convertDateTime>
                                                    </h:outputLabel>
                                                </p:column>
                                                <p:ajax event="focus" process="acStock :#{p:component('cmbPs')}"  ></p:ajax>
                                                <p:ajax event="itemSelect"   listener="#{pharmacySaleController3.handleSelect}"  update="txtQty txtRate focusQty :#{p:component('lstReplaceableBatch')}" ></p:ajax>
                                                <p:ajax event="query" update=":#{p:component('tabI')}" process="acStock"></p:ajax>
                                            </p:autoComplete>
                                        </h:panelGrid>

                                        <h:panelGrid columns="1" >
                                            <p:outputLabel value="Quentity" ></p:outputLabel>
                                            <p:inputText  accesskey="q"  autocomplete="off" id="txtQty" value="#{pharmacySaleController3.intQty}" style="width: 50px!important;"   >
                                                <p:ajax event="keyup"  listener="#{pharmacySaleController3.calculateBillItemListner}" process="acStock txtQty :#{p:component('cmbPs')}" update="txtRate txtVal" ></p:ajax>
                                                <p:ajax event="blur"  listener="#{pharmacySaleController3.calculateBillItemListner}" process="acStock txtQty :#{p:component('cmbPs')}" update="txtRate txtVal" ></p:ajax>
                                            </p:inputText>
                                        </h:panelGrid>

                                        <p:commandButton  accesskey="a" id="btnAdd" value="Add" 
                                                          action="#{pharmacySaleController3.addBillItemNew()}" 
                                                          process="@this acStock txtQty :#{p:component('cmbPs')}" 
                                                          update=":#{p:component('netTotal')} :#{p:component('dis')} :#{p:component('total')} :#{p:component('pBillDetails')} :#{p:component('tblBillItem')} txtRate txtQty acStock focusItem :#{p:component('tabI')} :#{p:component('panelError')}" ></p:commandButton>

                                        <h:panelGrid columns="1" >
                                            <p:outputLabel value="Rate" ></p:outputLabel>
                                            <p:outputLabel id="txtRate" value="#{pharmacySaleController3.billItem.netRate}" >
                                                <f:convertNumber pattern="#,##0.00" />
                                            </p:outputLabel>
                                        </h:panelGrid>
                                        <h:panelGrid columns="1" >
                                            <p:outputLabel value="Value" ></p:outputLabel>
                                            <p:outputLabel id="txtVal" value="#{pharmacySaleController3.billItem.netValue}" >
                                                <f:convertNumber pattern="#,##0.00" />
                                            </p:outputLabel>
                                        </h:panelGrid>
                                        <p:focus id="focusQty" for="txtQty" ></p:focus>
                                        <p:focus id="focusItem" for="acStock" ></p:focus>

                                    </h:panelGrid>


                                    <p:panel header="Bill Items" id="pBis">
                                        <p:dataTable id="tblBillItem" value="#{pharmacySaleController3.preBill.billItems}"
                                                     var="bi" rowIndexVar="s" editable="true" sortBy="#{bi.searialNo}" >

                                            <p:ajax event="rowEdit" listener="#{pharmacySaleController3.onEdit}" update="@this gros :#{p:component('pBillDetails')}" />  
                                            <p:ajax event="rowEditCancel" listener="#{pharmacySaleController3.onEdit}" update="@this gros :#{p:component('pBillDetails')}" /> 


                                            <p:column headerText="Item">
                                                <h:outputLabel value="#{bi.pharmaceuticalBillItem.itemBatch.item.name}" ></h:outputLabel>
                                            </p:column>
                                            <p:column headerText="Quentity">
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{bi.qty}" >
                                                            <f:convertNumber integerOnly="true" />
                                                        </h:outputText>
                                                    </f:facet>  
                                                    <f:facet name="input">  
                                                        <p:inputText autocomplete="off" id="ipTblQty" value="#{bi.qty}" style="width:96%"/>  
                                                    </f:facet>  
                                                </p:cellEditor> 
                                            </p:column>

                                            <p:column style="width:6%">  
                                                <p:rowEditor />  
                                            </p:column>  


                                            <p:column headerText="Rate">
                                                <h:outputLabel id="rate" value="#{bi.rate}" >
                                                    <f:convertNumber pattern="#,##0.00" />
                                                </h:outputLabel>
                                            </p:column>
                                            <p:column headerText="Value">
                                                <h:outputLabel value="#{bi.grossValue}" id="gros">
                                                    <f:convertNumber pattern="#,##0.00" />
                                                </h:outputLabel>
                                            </p:column>
                                            <p:column headerText="Expiry">
                                                <h:outputLabel value="#{bi.pharmaceuticalBillItem.itemBatch.dateOfExpire}" >
                                                    <f:convertDateTime pattern="dd MM yyyy" ></f:convertDateTime>
                                                </h:outputLabel>

                                            </p:column>
                                            <p:column headerText="Remove">
                                                <p:commandButton value="Remove" action="#{pharmacySaleController3.removeBillItem(bi)}" ajax="false" >

                                                </p:commandButton>
                                            </p:column>

                                        </p:dataTable>
                                    </p:panel>



                                </h:panelGrid>
                                <p:panel header="Availability" id="tabI" >

                                    <p:panelGrid columns="2" style="width: 100%;vertical-align: top;" styleClass="alignTop">

                                        <h:panelGroup >
                                            <h:outputLabel value="These " ></h:outputLabel>
                                            <b>
                                                <h:outputLabel value=" available Stocks " ></h:outputLabel>
                                            </b>

                                            <h:outputLabel value=" that can be used as " ></h:outputLabel>
                                            <b>
                                                <h:outputLabel value=" replacement." ></h:outputLabel>
                                            </b>




                                        </h:panelGroup>


                                        <h:panelGroup >
                                            <h:outputLabel value="Stocks " escape="false" ></h:outputLabel>
                                            <b>
                                                <h:outputLabel value=" NOT " escape="false" ></h:outputLabel>

                                                <i>
                                                    <h:outputLabel value=" available " escape="false" ></h:outputLabel>
                                                </i>
                                            </b>
                                            <h:outputLabel value=" for these tiems." escape="false" ></h:outputLabel>

                                        </h:panelGroup>

                                        <p:dataTable id="lstReplaceableBatch" 
                                                     selection="#{pharmacySaleController3.replacableStock}"
                                                     value="#{pharmacySaleController3.replaceableStocks}" 
                                                     var="ri" 
                                                     selectionMode="single"
                                                     rowKey="#{ri.id}"
                                                     emptyMessage="System can not detect suitable replacements.">
                                            <p:ajax event="rowSelect" process="@this" update=":#{p:component('acStock')}" listener="#{pharmacySaleController3.makeStockAsBillItemStock()}" ></p:ajax>
                                            <p:ajax event="rowUnselect" process="@this" update=":#{p:component('acStock')}" listener="#{pharmacySaleController3.makeStockAsBillItemStock()}" ></p:ajax>
                                            <p:column headerText="Item">
                                                #{ri.itemBatch.item.name}
                                            </p:column>
                                            <p:column headerText="Code">
                                                #{ri.itemBatch.item.code}
                                            </p:column>
                                            <p:column headerText="Rate"  style="text-align: right;">
                                                <p:outputLabel value="#{ri.itemBatch.retailsaleRate}">
                                                    <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                </p:outputLabel>
                                            </p:column>
                                            <p:column headerText="Stocks" style="text-align: right;">
                                                <p:outputLabel value="#{ri.stock}"  style="width: 50px!important;">
                                                    <f:convertNumber pattern="#,###" ></f:convertNumber>
                                                </p:outputLabel>
                                            </p:column>
                                            <p:column headerText="Expiry">
                                                <h:panelGroup rendered="#{commonController.currentDateTime > ri.itemBatch.dateOfExpire}" >
                                                    <p:outputLabel value="#{ri.itemBatch.dateOfExpire}" styleClass="ui-messages-fatal"  >
                                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                                    </p:outputLabel>
                                                </h:panelGroup>
                                                <h:panelGroup rendered="#{ri.itemBatch.dateOfExpire > commonController.currentDateTime}" >
                                                    <p:outputLabel value="#{ri.itemBatch.dateOfExpire}" >
                                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                                    </p:outputLabel>
                                                </h:panelGroup>
                                            </p:column>
                                        </p:dataTable>

                                        <p:dataTable id="lstSelectItems" 
                                                     selection="#{pharmacySaleController3.selectedAvailableAmp}"
                                                     value="#{pharmacySaleController3.itemsWithoutStocks}" 
                                                     var="si" 
                                                     selectionMode="single"
                                                     rowKey="#{si.id}"
                                                     emptyMessage="No items with that name without stocks.">
                                            <p:ajax event="rowSelect" process="@this" update=":#{p:component('lstReplaceableBatch')}" listener="#{pharmacySaleController3.selectReplaceableStocksNew()}" ></p:ajax>
                                            <p:ajax event="rowUnselect" process="@this" update=":#{p:component('lstReplaceableBatch')}" listener="#{pharmacySaleController3.selectReplaceableStocksNew()}" ></p:ajax>
                                            <p:column headerText="Generic">
                                                #{si.vmp.name}
                                            </p:column>
                                            <p:column headerText="Name">
                                                <span class="ui-messages-info-icon" ></span>
                                                #{si.name}
                                            </p:column>

                                        </p:dataTable>
                                    </p:panelGrid>
                                </p:panel> 

                            </p:panel>




                            <p:panel>


                                <f:facet name="header" >
                                    <h:panelGrid columns="20"  >

                                        <h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;" style="min-width: 50px;" />
                                        <p:selectOneMenu   id="pay" value="#{pharmacySaleController3.paymentMethod}">    
                                            <f:selectItems value="#{enumController.paymentMethods}"/>
                                            <p:ajax process="@this cmbPs " 
                                                    update="pBillDetails creditCard cheque slip tvPt" 
                                                    event="change"  
                                                    listener="#{pharmacySaleController3.changeListener()}"/>
                                        </p:selectOneMenu>

                                        <p:selectOneMenu   id="cmbPs" value="#{pharmacySaleController3.paymentScheme}">   
                                            <f:selectItem itemLabel="Discount Scheme"/>
                                            <f:selectItems value="#{paymentSchemeController.paymentSchemesForPharmacy}" var="i" itemLabel="#{i.name}" itemValue="#{i}"/>
                                            <p:ajax process="@this pay " 
                                                    update="pBillDetails creditCard cheque slip" 
                                                    event="change"  
                                                    listener="#{pharmacySaleController3.changeListener()}"/>
                                        </p:selectOneMenu>



                                        <h:panelGroup id="creditCard" style="display: #{pharmacySaleController3.paymentMethod ne 'Card' ? 'none' : 'block'} ; ">
                                            <pa:creditCard paymentMethodData="#{pharmacySaleController3.paymentMethodData}"/>
                                        </h:panelGroup>

                                        <h:panelGroup id="cheque" style="display: #{pharmacySaleController3.paymentMethod ne 'Cheque' ? 'none' : 'block'} ; " >
                                            <pa:cheque paymentMethodData="#{pharmacySaleController3.paymentMethodData}"/>
                                        </h:panelGroup>

                                        <h:panelGroup id="slip" style="display: #{pharmacySaleController3.paymentMethod ne 'Slip' ? 'none' : 'block'} ;">
                                            <pa:slip paymentMethodData="#{pharmacySaleController3.paymentMethodData}"/>
                                        </h:panelGroup>

                                        <p:commandButton ajax="false" accesskey="s" value="Settle" 
                                                         onclick="onSubmitButton();"
                                                         action="#{pharmacySaleController3.settleBillWithPay}" >
                                            <f:facet name="title" >
                                                <h:outputLabel value="S" style="text-decoration: underline;" ></h:outputLabel>
                                                <h:outputLabel value="ettle"  ></h:outputLabel>
                                            </f:facet>
                                        </p:commandButton>
                                        <p:commandButton accesskey="n" value="New Pharmacy Bill"  
                                                         ajax="false" action="pharmacy_bill_retail_sale_3"
                                                         onclick="onSubmitButton();"
                                                         actionListener="#{pharmacySaleController3.resetAll()}"  ></p:commandButton>


                                    </h:panelGrid>


                                </f:facet>

                                <p:panelGrid columns="2">
                                    <p:outputLabel value="Referring Doctor" ></p:outputLabel>
                                    <p:autoComplete forceSelection="true" id="cmbDoc" value="#{pharmacySaleController3.preBill.referredBy}" 
                                                    completeMethod="#{doctorController.completeDoctor}" 
                                                    var="ix" itemLabel="#{ix.person.name}" 
                                                    itemValue="#{ix}" size="30"  
                                                    >
                                    </p:autoComplete>
                                    <p:outputLabel value="Comments" ></p:outputLabel>
                                    <p:inputTextarea value="#{pharmacySaleController3.comment}" id="comment"/>



                                </p:panelGrid>


                                <p:panel header="Bill Details" id="pBillDetails"  >
                                    <p:panelGrid columns="2" columnClasses="numberCol, textCol"  >
                                        <h:outputLabel value="Total" ></h:outputLabel>
                                        <h:outputLabel id="total" value="#{pharmacySaleController3.preBill.total}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel value="Discount" ></h:outputLabel>
                                        <h:outputLabel id="dis" value="#{pharmacySaleController3.preBill.discount}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                            <p:ajax process="total dis netTotal paid" update="balance netTotal" event="blur"/>
                                        </h:outputLabel>
                                        <h:outputLabel value="Net Total" ></h:outputLabel>
                                        <h:outputLabel id="netTotal" value="#{pharmacySaleController3.preBill.netTotal}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel  value="Tendered" ></h:outputLabel>
                                        <p:inputText autocomplete="off" accesskey="t" id="paid" value="#{pharmacySaleController3.cashPaid}" >
                                            <p:ajax process="total dis netTotal paid" update="balance netTotal" event="blur"/>
                                        </p:inputText>
                                        <h:outputLabel  value="Balance" ></h:outputLabel>
                                        <h:outputLabel id="balance" value="#{pharmacySaleController3.balance}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </p:panelGrid>

                                </p:panel>

                                <p:panel header="Client Detail"> 


                                    <p:tabView id="tvPt" style="min-height: 250px;"  activeIndex="#{pharmacySaleController3.patientSearchTab}" >
                                        <p:ajax event="tabChange"  process="@this"
                                                update=":#{p:component('cmbPs')} :#{p:component('pBillDetails')}"
                                                listener="#{pharmacySaleController3.onTabChange}" />

                                        <p:tab id="tabNewPt" title="New Patient"  >
                                            <bil:newPatient controller="#{pharmacySaleController3}"/>
                                        </p:tab>

                                        <p:tab id="tabSearchPt" title="Search Patient" >

                                            <p:selectBooleanCheckbox value="#{patientController.reportKeyWord.additionalDetails}" 
                                                                     itemLabel="Serch Only Registed Patient" >
                                                <f:ajax execute="@this" render="acPt" />
                                            </p:selectBooleanCheckbox>
                                            <p:autoComplete
                                                widgetVar="aPt" 
                                                id="acPt" forceSelection="true" 
                                                value="#{pharmacySaleController3.searchedPatient}" 
                                                completeMethod="#{patientController.completePatientByNameOrCode}" 
                                                var="apt" itemLabel="#{apt.person.name}" 
                                                itemValue="#{apt}" size="30"  
                                                style="width: 400px;"
                                                disabled="#{pharmacySaleController3.fromOpdEncounter}">
                                                <p:column headerText="Name">
                                                    <h:outputLabel value="#{apt.person.nameWithTitle}" />
                                                </p:column>
                                                <p:column headerText="Age">
                                                    <h:outputLabel value="#{apt.age}" />
                                                </p:column>
                                                <p:column headerText="NIC">
                                                    <h:outputLabel value="#{apt.person.nic}"/>
                                                </p:column>
                                                <p:column headerText="Code">
                                                    <h:outputLabel value="#{apt.code}" />
                                                </p:column>
                                                <p:column headerText="PHN">
                                                    <h:outputLabel value="#{apt.phn}"/>
                                                </p:column>
                                                <p:column headerText="Sex">
                                                    <h:outputLabel value="#{apt.person.sex}" />
                                                </p:column>
                                                <p:column headerText="Address">
                                                    <h:outputLabel value="#{apt.person.address}" />
                                                </p:column>
                                                <p:column headerText="Date of Birth">
                                                    <h:outputLabel value="#{apt.person.dob}" >
                                                        <f:convertDateTime pattern="dd MMMM yyyy"/>
                                                    </h:outputLabel>
                                                </p:column>
                                                <p:ajax event="itemSelect" process="@this" update=":#{p:component('cmbPs')} :#{p:component('pBillDetails')} panSearch"
                                                        listener="#{pharmacySaleController3.searchPatientListener}"/>
                                            </p:autoComplete>  
                                            <h:panelGroup id="panSearch">
                                                <pat:searchPatientDetail patient="#{pharmacySaleController3.searchedPatient}"  />
                                            </h:panelGroup>
                                            <div style="padding: 2px; margin: 2px; border: 1px solid;">
                                                <p:outputLabel value="#{pharmacySaleController3.opdEncounterComments}" ></p:outputLabel>
                                            </div>
                                        </p:tab>

                                        <p:tab id="tabCredit" title="Credit"  >
                                            <p:panelGrid columns="3" >
                                                <p:outputLabel value="Credit Company" ></p:outputLabel>
                                                <p:autoComplete  style="width: 400px;" 

                                                                 forceSelection="true" 
                                                                 value="#{pharmacySaleController3.toInstitution}" 
                                                                 id="scCreditCompany"
                                                                 completeMethod="#{institutionController.completeCreditCompany}" 
                                                                 var="myi" itemLabel="#{myi.name}" 
                                                                 itemValue="#{myi}"
                                                                 converter="institutionConverter" 
                                                                 disabled="#{pharmacySaleController3.paymentMethod ne 'Credit' }">

                                                    <p:ajax process="scCreditCompany" update=":#{p:component('pBillDetails')}" 
                                                            event="itemSelect"  listener="#{pharmacySaleController3.paymentSchemeChanged}" />

                                                </p:autoComplete>
                                                <p:watermark for="scCreditCompany" value="Type at least 3 charactors of Company" ></p:watermark>

                                                <p:outputLabel value="Staff Member" ></p:outputLabel>
                                                <p:autoComplete  style="width: 400px;" 
                                                                 forceSelection="true" 
                                                                 value="#{pharmacySaleController3.toStaff}" 
                                                                 id="scStaff"
                                                                 completeMethod="#{staffController.completeStaff}" 
                                                                 var="mys" 
                                                                 itemLabel="#{mys.person.nameWithTitle}" 
                                                                 itemValue="#{mys}"
                                                                 converter="stfcon" 
                                                                 disabled="#{pharmacySaleController3.paymentMethod ne 'Credit' }">
                                                    <p:column headerText="Name" >
                                                        <h:outputLabel value="#{mys.person.nameWithTitle}" ></h:outputLabel>
                                                    </p:column>
                                                    <p:column headerText="Annual Entitlement">
                                                        <h:outputLabel value="#{mys.annualWelfareQualified}" >
                                                            <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                        </h:outputLabel>
                                                    </p:column>
                                                    <p:column  headerText="Annual Utilized Value">
                                                        <h:outputLabel value="#{mys.annualWelfareUtilized}" >
                                                            <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                        </h:outputLabel>
                                                    </p:column>

                                                    <p:ajax process="scStaff" update=":#{p:component('pBillDetails')}" 
                                                            event="itemSelect"  listener="#{pharmacySaleController3.paymentSchemeChanged}" />

                                                </p:autoComplete>
                                                <p:watermark for="scStaff" value="Type at least 3 charactors of Staff member." ></p:watermark>
                                            </p:panelGrid>
                                        </p:tab>



                                    </p:tabView>



                                </p:panel>



                            </p:panel>

                        </h:panelGrid>
                    </p:panel>


                </h:form>

                <h:form>


                    <p:panel  rendered="#{pharmacySaleController3.billPreview}" >




                        <p:commandButton id="nullButton3" value="No Action"
                                         action="#" style="display: none;" ></p:commandButton>
                        <p:defaultCommand  target="btnPrint" />  

                        <div class="nonPrintBlock" >
                            <p:commandButton accesskey="p" id="btnPrint" value="Print" ajax="false" action="#" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>
                            <p:commandButton accesskey="n" value="New Pharmacy Bill"  
                                             ajax="false" action="pharmacy_bill_retail_sale_3" 
                                             onclick="onSubmitButton();"
                                             actionListener="#{pharmacySaleController3.resetAll()}" ></p:commandButton>

                            <p:commandButton value="Sale 1" action="pharmacy_bill_retail_sale" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController.pharmacyRetailSale()}" />
                            <p:commandButton value="Sale 2" action="pharmacy_bill_retail_sale_1" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController1.pharmacyRetailSale()}" />
                            <p:commandButton value="Sale 3" action="pharmacy_bill_retail_sale_2" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController2.pharmacyRetailSale()}" />
                            <p:commandButton disabled="true" value="Sale 4" action="pharmacy_bill_retail_sale_3" rendered="#{webUserController.hasPrivilege('PharmacySale')}" actionListener="#{pharmacySaleController3.pharmacyRetailSale()}" />


                        </div>
                        <div >
                            <h:panelGroup   id="gpBillPreview"   > 
                                <phi:saleBill bill="#{pharmacySaleController3.printBill}"></phi:saleBill>
                            </h:panelGroup>
                        </div>



                    </p:panel>



                </h:form>

            </ui:define>

        </ui:composition>

    </h:body>
</html>
